home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / libs / src / pset / ops.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-25  |  968 b   |  52 lines

  1. /*
  2.  * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. static char RCSid[] = "$Id: ops.c,v 3.1 1993/03/13 23:21:53 panos Exp $" ;
  8.  
  9. #include "pset.h"
  10.  
  11. #define PRIVATE                static
  12. #define POINTER                __pset_pointer
  13.  
  14. #ifndef NULL
  15. #define NULL                    0
  16. #endif
  17.  
  18.  
  19. /*
  20.  * Remove all NULL pointers from a pset
  21.  */
  22. void pset_compact( pset )
  23.     register pset_h pset ;
  24. {
  25.     register unsigned u ;
  26.  
  27.     for ( u = 0 ; u < pset_count( pset ) ; )
  28.         if ( pset_pointer( pset, u ) != NULL )
  29.             u++ ;
  30.         else
  31.             pset_remove_index( pset, u ) ;
  32. }
  33.  
  34.  
  35. /*
  36.  * Apply a function to all pointers of a pset
  37.  */
  38. void pset_apply( pset, func, arg )
  39.     register pset_h pset ;
  40.     register void (*func)() ;
  41.     register void *arg ;
  42. {
  43.     register unsigned u ;
  44.  
  45.     for ( u = 0 ; u < pset_count( pset ) ; u++ )
  46.         if ( arg )
  47.             (*func)( arg, pset_pointer( pset, u ) ) ;
  48.         else
  49.             (*func)( pset_pointer( pset, u ) ) ;
  50. }
  51.  
  52.